package com.session;

import java.io.IOException;
import java.io.Writer;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebServlet("/JspSession")
public class JspSession extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String name=req.getParameter("name");
		String psw=req.getParameter("password");
		System.out.println("输出"+name+","+psw);
		HttpSession session=req.getSession(true);
		session.setAttribute("name", name);
		session.setAttribute("password", psw);
		System.out.println(session.getAttribute("name")+","+session.getAttribute("password"));
		resp.sendRedirect("receive.jsp");
		
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
